<!doctype html>
<html lang="en-US">
  <head>
    <link href="/assets/index.css" rel="stylesheet" type="text/css" />
    <script crossorigin="anonymous" src="https://unpkg.com/@babel/standalone@7.8.7/babel.min.js"></script>
    <script crossorigin="anonymous" src="https://unpkg.com/react@16.8.6/umd/react.production.min.js"></script>
    <script crossorigin="anonymous" src="https://unpkg.com/react-dom@16.8.6/umd/react-dom.production.min.js"></script>
    <script crossorigin="anonymous" src="/test-harness.js"></script>
    <script crossorigin="anonymous" src="/test-page-object.js"></script>
    <script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
  </head>
  <body>
    <main id="webchat"></main>
    <script type="text/babel">
      run(async function () {
        const {
          ReactDOM: { render },
          WebChat: {
            Components: { BasicWebChat, Composer },
            hooks: { useTypingIndicatorVisible }
          }
        } = window; // Imports in UMD fashion.

        const directLine = WebChat.createDirectLine({ token: await testHelpers.token.fetchDirectLineToken() });
        const store = testHelpers.createStore();

        let typingIndicatorVisible;

        const RunFunction = () => {
          [typingIndicatorVisible] = useTypingIndicatorVisible();

          return false;
        };

        render(
          <Composer directLine={directLine} store={store}>
            <BasicWebChat />
            <RunFunction />
          </Composer>,
          document.getElementById('webchat')
        );

        await pageConditions.uiConnected();

        expect(typingIndicatorVisible).toBe(false);
      });
    </script>
  </body>
</html>
